//
//  HMStatus.swift
//  GuoGuo
//
//  Created by 艾小新 on 16/8/5.
//  Copyright © 2016年 xiaoxin. All rights reserved.
//

import UIKit

class HMStatus: NSObject {
    
   
    // 微博内容
    var text: String?
    // 当前微博的创建时间
    var created_at: String?
    // 微博来源
    var source: String?
    // 当前发送此条微博的用户信息
    var user: HMUser?
    // 转发数量
    var reposts_count: Int = 0
    // 评论数量
    var comments_count: Int = 0
    // 点赞数量
    var attitudes_count: Int = 0
    
    var id: Int64 = 0
    // 转发微博，模型嵌套模型
    var retweeted_status: HMStatus?
    // 微博配图s
    var pic_urls: [HMPictureInfo]?


    init(dict: [String:AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let v = value as? [String: AnyObject] else {
                return
            }
            user = HMUser(dict: v)
        } else if key == "retweeted_status" {
            guard let v = value as? [String:AnyObject] else {
                return
            }
            retweeted_status = HMStatus(dict: v)
        } else if key == "pic_urls" {
            guard let v = value as? [[String:AnyObject]] else {
                return
            }
            var tempArray = [HMPictureInfo]()
            for i in v {            
                tempArray.append(HMPictureInfo(dict: i))
            }
            self.pic_urls = tempArray
        } else{
            super.setValue(value, forKey: key)
        }
    }
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    

}
